#!/bin/bash

CLIENT=$1
CSTORE=$2

MAINDIR=$PWD

cd /etc/openvpn/easy-rsa/
./easyrsa --batch revoke $CLIENT
./easyrsa gen-crl
rm -rf pki/reqs/$CLIENT.req
rm -rf pki/private/$CLIENT.key
rm -rf pki/issued/$CLIENT.crt
rm -rf /etc/openvpn/crl.pem
cp /etc/openvpn/easy-rsa/pki/crl.pem /etc/openvpn/crl.pem

rm -rf $CSTORE/$CLIENT.ovpn

chown nobody:nogroup /etc/openvpn/crl.pem

cd $MAINDIR

echo "Restarting Server..."

./bin/stop
./bin/start